//
//  DestinationViewController.m
//  穷游
//
//  Created by lanou3g on 15/12/17.
//  Copyright © 2015年 王忠奎. All rights reserved.
//

#import "DestinationViewController.h"
#import "DesTableViewCell.h"
#import "DesView.h"
#import "DesDataHandle.h"
#import "DesModel.h"
#import "DesDetailViewController.h"
@interface DestinationViewController ()<UITableViewDataSource,UITableViewDelegate>

@property(nonatomic,strong)DesView *desView;

@property(nonatomic,strong)NSArray *arr;

@end

@implementation DestinationViewController


-(void)loadView
{

    self.desView = [[DesView alloc]initWithFrame:[UIScreen mainScreen].bounds];
    self.view = self.desView;


}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"七大洲";
   
    //设置代理
    self.desView.tableView.dataSource = self;
    self.desView.tableView.delegate = self;
    
    //注册xib
    [self.desView.tableView registerNib:[UINib nibWithNibName:@"DesTableViewCell" bundle:nil]forCellReuseIdentifier:@"DesTableViewCell"];
   
    [[DesDataHandle sharedDesDataHandle] getDesDataFromNet:^(id isFinished, id dict) {
        self.arr = isFinished;
        [self.desView.tableView reloadData];
    }];


}

#pragma mark ---实现代理方法
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{

    return 1;

}


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{

    
    return [DesDataHandle sharedDesDataHandle].desZhouArray.count;

}


-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    DesTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"DesTableViewCell"];
//    DesModel *model = [DesDataHandle sharedDesDataHandle].desZhouArray[indexPath.row];
//    [cell setCellDataWithModel:model];
    cell.nameLabel.text = self.arr[indexPath.row];
    
 
    return cell;


}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{

    return 120;

}

#pragma mark ---取消选中状态
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    DesDetailViewController *controller = [[DesDetailViewController alloc]init];
    [self.navigationController pushViewController:controller animated:YES];
//    controller.model = self.arr[indexPath.row];
   [DesDataHandle sharedDesDataHandle].key =self.arr[indexPath.row];


}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
